/**
 *
 * 订单列表接口
 *
 */
const router = require('express').Router();
const tips = require('../../../common/tips');
const log = require('../../../common/log');


router.post('/list', async (req, res, next) => {
    log.api('---- order list api ----');

    const r = req.body;
    const page = r.page ? r.page : 1;
    const size = r.size ? r.size : 10;
    const offset = (page - 1) * size;

    try {
        const addressTotal = '';
        const maxPage = Math.ceil(addressTotal[0].total / size);

        if (page > maxPage) {
            res.json({
                code: tips.page.maxPageCode,
                msg: tips.page.maxPage,
                // result: {maxpage:maxPage}
            })
            return;
        }

        let list_rows = '';

        res.json({
            code: tips.successCode,
            msg: tips.success,
            result: {
                list: list_rows,
                maxtotal: addressTotal[0].total
                // maxpage: maxPage
            }
        })
    } catch (e) {
        console.log(tips.fail + e)
        res.json({
            code: tips.failCode,
            msg: tips.fail
        })
    }
});

module.exports = router;